package com.shroo8.footballblog.controllers.api;

import java.util.ArrayList;
import java.util.Locale;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shroo8.footballblog.bo.api.GetArticlesBo;
import com.shroo8.footballblog.dto.api.ArticleDto;

@Controller
public class GetArticlesController {
	private static final Logger logger = LoggerFactory.getLogger(GetArticlesController.class);

	@Resource(name="getArticlesBo", type=com.shroo8.footballblog.bo.api.GetArticlesBoImpl.class)
	private GetArticlesBo getArticlesBo;
	
	@RequestMapping(value = "/authors/{authorType}/{authorExternalId}/articles", method = RequestMethod.GET)
	public @ResponseBody ArrayList<ArticleDto> getArticles(Locale locale, @PathVariable("authorType") String authorType, 
			@PathVariable("authorExternalId") int authorExternalId) {
		logger.info("Welcome to get author Articles! The client locale is {}.", locale);		
		return getArticlesBo.getArticles(authorType, authorExternalId);
	}
}
